package com.leader.say.controller;

import com.leader.say.entity.Student;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.*;

@Controller
public class freemarkerController {


    @RequestMapping("/test1")
    public String test1(Map<String, Object> map) {
        /* 普通字符串 */
        map.put("name", "杨超越");


        Student stu = new Student("stu", 11, new Date(), 1.11f, null, null);
        Student stu2 = new Student("stu2", 22, new Date(), 2.22f, null, null);
        Student stu3 = new Student("stu3", 33, new Date(), 3.33f, null, null);
        Student stu4 = new Student("stu4", 44, new Date(), 4.44f, null, null);

        /* List 集合 */
        List<Student> students = new ArrayList<>();
        stu.setFriends(students);
        stu2.setFriends(students);
        stu3.setFriends(students);
        stu4.setFriends(students);
        stu.setBestFriend(stu2);
        stu2.setBestFriend(stu3);
        stu3.setBestFriend(stu4);
        stu4.setBestFriend(stu);
        students.add(stu);
        students.add(stu2);
        students.add(stu3);
        students.add(stu4);
        map.put("students", students);

        /* HashMap 集合 */
        HashMap<String, Student> hashMap = new HashMap();
        hashMap.put("stu", stu);
        hashMap.put("stu2", stu2);
        hashMap.put("stu3", stu3);
        hashMap.put("stu4", stu4);
        map.put("hashMap", hashMap);

        /* 内建函数 之 日期转换 */
        Date today = new Date();
        map.put("today", today);

        /* 内建函数 之 内建函数C */
        map.put("number", 1234567890);

        return "test1";
    }

}
